home *** CD-ROM | disk | FTP | other *** search
/ Champak 86 / (Vol 86) My Disc.iso / Interface / it.dig / scripts / __Packages / mx / core / ScrollView.as < prev    next >
Text File  |  2009-06-09  |  11KB  |  360 lines

  1. class mx.core.ScrollView extends mx.core.View
  2. {
  3.    static var symbolName = "ScrollView";
  4.    static var symbolOwner = mx.core.ScrollView;
  5.    static var version = "2.0.2.127";
  6.    var className = "ScrollView";
  7.    var __vScrollPolicy = "auto";
  8.    var __hScrollPolicy = "off";
  9.    var __vPosition = 0;
  10.    var __hPosition = 0;
  11.    var numberOfCols = 0;
  12.    var rowC = 0;
  13.    var columnWidth = 1;
  14.    var rowH = 0;
  15.    var heightPadding = 0;
  16.    var widthPadding = 0;
  17.    var MASK_DEPTH = 10000;
  18.    function ScrollView()
  19.    {
  20.       super();
  21.    }
  22.    function getHScrollPolicy(Void)
  23.    {
  24.       return this.__hScrollPolicy;
  25.    }
  26.    function setHScrollPolicy(policy)
  27.    {
  28.       this.__hScrollPolicy = policy.toLowerCase();
  29.       if(this.__width == undefined)
  30.       {
  31.          return undefined;
  32.       }
  33.       this.setScrollProperties(this.numberOfCols,this.columnWidth,this.rowC,this.rowH,this.heightPadding,this.widthPadding);
  34.    }
  35.    function get hScrollPolicy()
  36.    {
  37.       return this.getHScrollPolicy();
  38.    }
  39.    function set hScrollPolicy(policy)
  40.    {
  41.       this.setHScrollPolicy(policy);
  42.    }
  43.    function getVScrollPolicy(Void)
  44.    {
  45.       return this.__vScrollPolicy;
  46.    }
  47.    function setVScrollPolicy(policy)
  48.    {
  49.       this.__vScrollPolicy = policy.toLowerCase();
  50.       if(this.__width == undefined)
  51.       {
  52.          return undefined;
  53.       }
  54.       this.setScrollProperties(this.numberOfCols,this.columnWidth,this.rowC,this.rowH,this.heightPadding,this.widthPadding);
  55.    }
  56.    function get vScrollPolicy()
  57.    {
  58.       return this.getVScrollPolicy();
  59.    }
  60.    function set vScrollPolicy(policy)
  61.    {
  62.       this.setVScrollPolicy(policy);
  63.    }
  64.    function get hPosition()
  65.    {
  66.       return this.getHPosition();
  67.    }
  68.    function set hPosition(pos)
  69.    {
  70.       this.setHPosition(pos);
  71.    }
  72.    function getHPosition(Void)
  73.    {
  74.       return this.__hPosition;
  75.    }
  76.    function setHPosition(pos)
  77.    {
  78.       this.hScroller.__set__scrollPosition(pos);
  79.       this.__hPosition = pos;
  80.    }
  81.    function get vPosition()
  82.    {
  83.       return this.getVPosition();
  84.    }
  85.    function set vPosition(pos)
  86.    {
  87.       this.setVPosition(pos);
  88.    }
  89.    function getVPosition(Void)
  90.    {
  91.       return this.__vPosition;
  92.    }
  93.    function setVPosition(pos)
  94.    {
  95.       this.vScroller.__set__scrollPosition(pos);
  96.       this.__vPosition = pos;
  97.    }
  98.    function get maxVPosition()
  99.    {
  100.       var _loc2_ = this.vScroller.maxPos;
  101.       return _loc2_ != undefined ? _loc2_ : 0;
  102.    }
  103.    function get maxHPosition()
  104.    {
  105.       return this.getMaxHPosition();
  106.    }
  107.    function set maxHPosition(pos)
  108.    {
  109.       this.setMaxHPosition(pos);
  110.    }
  111.    function getMaxHPosition(Void)
  112.    {
  113.       if(this.__maxHPosition != undefined)
  114.       {
  115.          return this.__maxHPosition;
  116.       }
  117.       var _loc2_ = this.hScroller.maxPos;
  118.       return _loc2_ != undefined ? _loc2_ : 0;
  119.    }
  120.    function setMaxHPosition(pos)
  121.    {
  122.       this.__maxHPosition = pos;
  123.    }
  124.    function setScrollProperties(colCount, colWidth, rwCount, rwHeight, hPadding, wPadding)
  125.    {
  126.       var _loc3_ = this.getViewMetrics();
  127.       if(hPadding == undefined)
  128.       {
  129.          hPadding = 0;
  130.       }
  131.       if(wPadding == undefined)
  132.       {
  133.          wPadding = 0;
  134.       }
  135.       this.propsInited = true;
  136.       delete this.scrollAreaChanged;
  137.       this.heightPadding = hPadding;
  138.       this.widthPadding = wPadding;
  139.       if(colWidth == 0)
  140.       {
  141.          colWidth = 1;
  142.       }
  143.       if(rwHeight == 0)
  144.       {
  145.          rwHeight = 1;
  146.       }
  147.       var _loc4_ = Math.ceil((this.__width - _loc3_.left - _loc3_.right - this.widthPadding) / colWidth);
  148.       if(this.__hScrollPolicy == "on" || _loc4_ < colCount && this.__hScrollPolicy == "auto")
  149.       {
  150.          if(this.hScroller == undefined || this.specialHScrollCase)
  151.          {
  152.             delete this.specialHScrollCase;
  153.             this.hScroller = mx.controls.scrollClasses.ScrollBar(this.createObject("HScrollBar","hSB",1001));
  154.             this.hScroller.__set__lineScrollSize(20);
  155.             this.hScroller.scrollHandler = this.scrollProxy;
  156.             this.hScroller.__set__scrollPosition(this.__hPosition);
  157.             this.scrollAreaChanged = true;
  158.          }
  159.          if(this.numberOfCols != colCount || this.columnWidth != colWidth || this.viewableColumns != _loc4_ || this.scrollAreaChanged)
  160.          {
  161.             this.hScroller.setScrollProperties(_loc4_,0,colCount - _loc4_);
  162.             this.viewableColumns = _loc4_;
  163.             this.numberOfCols = colCount;
  164.             this.columnWidth = colWidth;
  165.          }
  166.       }
  167.       else if((this.__hScrollPolicy == "auto" || this.__hScrollPolicy == "off") && this.hScroller != undefined)
  168.       {
  169.          this.hScroller.removeMovieClip();
  170.          delete this.hScroller;
  171.          this.scrollAreaChanged = true;
  172.       }
  173.       if(this.heightPadding == undefined)
  174.       {
  175.          this.heightPadding = 0;
  176.       }
  177.       var _loc5_ = Math.ceil((this.__height - _loc3_.top - _loc3_.bottom - this.heightPadding) / rwHeight);
  178.       var _loc8_ = (this.__height - _loc3_.top - _loc3_.bottom) % rwHeight != 0;
  179.       if(this.__vScrollPolicy == "on" || _loc5_ < rwCount + _loc8_ && this.__vScrollPolicy == "auto")
  180.       {
  181.          if(this.vScroller == undefined)
  182.          {
  183.             this.vScroller = mx.controls.scrollClasses.ScrollBar(this.createObject("VScrollBar","vSB",1002));
  184.             this.vScroller.scrollHandler = this.scrollProxy;
  185.             this.vScroller.__set__scrollPosition(this.__vPosition);
  186.             this.scrollAreaChanged = true;
  187.             this.rowH = 0;
  188.          }
  189.          if(this.rowC != rwCount || this.rowH != rwHeight || this.viewableRows + _loc8_ != _loc5_ + this.oldRndUp || this.scrollAreaChanged)
  190.          {
  191.             this.vScroller.setScrollProperties(_loc5_,0,rwCount - _loc5_ + _loc8_);
  192.             this.viewableRows = _loc5_;
  193.             this.rowC = rwCount;
  194.             this.rowH = rwHeight;
  195.             this.oldRndUp = _loc8_;
  196.          }
  197.       }
  198.       else if((this.__vScrollPolicy == "auto" || this.__vScrollPolicy == "off") && this.vScroller != undefined)
  199.       {
  200.          this.vScroller.removeMovieClip();
  201.          delete this.vScroller;
  202.          this.scrollAreaChanged = true;
  203.       }
  204.       this.numberOfCols = colCount;
  205.       this.columnWidth = colWidth;
  206.       if(this.scrollAreaChanged)
  207.       {
  208.          this.doLayout();
  209.          var _loc2_ = this.__viewMetrics;
  210.          var _loc12_ = this.owner == undefined ? this : this.owner;
  211.          _loc12_.layoutContent(_loc2_.left,_loc2_.top,this.columnWidth * this.numberOfCols - _loc2_.left - _loc2_.right,this.rowC * this.rowH,this.__width - _loc2_.left - _loc2_.right,this.__height - _loc2_.top - _loc2_.bottom);
  212.       }
  213.       if(!this.enabled)
  214.       {
  215.          this.setEnabled(false);
  216.       }
  217.    }
  218.    function getViewMetrics(Void)
  219.    {
  220.       var _loc2_ = this.__viewMetrics;
  221.       var _loc3_ = this.border_mc.__get__borderMetrics();
  222.       _loc2_.left = _loc3_.left;
  223.       _loc2_.right = _loc3_.right;
  224.       if(this.vScroller != undefined)
  225.       {
  226.          _loc2_.right += this.vScroller.minWidth;
  227.       }
  228.       _loc2_.top = _loc3_.top;
  229.       if(this.hScroller == undefined && (this.__hScrollPolicy == "on" || this.__hScrollPolicy == true))
  230.       {
  231.          this.hScroller = mx.controls.scrollClasses.ScrollBar(this.createObject("FHScrollBar","hSB",1001));
  232.          this.specialHScrollCase = true;
  233.       }
  234.       _loc2_.bottom = _loc3_.bottom;
  235.       if(this.hScroller != undefined)
  236.       {
  237.          _loc2_.bottom += this.hScroller.minHeight;
  238.       }
  239.       return _loc2_;
  240.    }
  241.    function doLayout(Void)
  242.    {
  243.       var _loc10_ = this.__get__width();
  244.       var _loc8_ = this.__get__height();
  245.       delete this.invLayout;
  246.       var _loc0_ = null;
  247.       var _loc3_ = this.__viewMetrics = this.getViewMetrics();
  248.       var _loc2_ = _loc3_.left;
  249.       var _loc9_ = _loc3_.right;
  250.       var _loc5_ = _loc3_.top;
  251.       var _loc11_ = _loc3_.bottom;
  252.       var _loc7_ = this.hScroller;
  253.       var _loc6_ = this.vScroller;
  254.       _loc7_.setSize(_loc10_ - _loc2_ - _loc9_,_loc7_.minHeight + 0);
  255.       _loc7_.move(_loc2_,_loc8_ - _loc11_);
  256.       _loc6_.setSize(_loc6_.minWidth + 0,_loc8_ - _loc5_ - _loc11_);
  257.       _loc6_.move(_loc10_ - _loc9_,_loc5_);
  258.       var _loc4_ = this.mask_mc;
  259.       _loc4_._width = _loc10_ - _loc2_ - _loc9_;
  260.       _loc4_._height = _loc8_ - _loc5_ - _loc11_;
  261.       _loc4_._x = _loc2_;
  262.       _loc4_._y = _loc5_;
  263.    }
  264.    function createChild(id, name, props)
  265.    {
  266.       var _loc2_ = super.createChild(id,name,props);
  267.       return _loc2_;
  268.    }
  269.    function init(Void)
  270.    {
  271.       super.init();
  272.       this.__viewMetrics = new Object();
  273.       if(_global.__SVMouseWheelManager == undefined)
  274.       {
  275.          var _loc0_ = null;
  276.          var _loc4_ = _global.__SVMouseWheelManager = new Object();
  277.          _loc4_.onMouseWheel = this.__onMouseWheel;
  278.          Mouse.addListener(_loc4_);
  279.       }
  280.    }
  281.    function __onMouseWheel(delta, scrollTarget)
  282.    {
  283.       var _loc4_ = scrollTarget;
  284.       var _loc1_ = undefined;
  285.       while(_loc4_ != undefined)
  286.       {
  287.          if(_loc4_ instanceof mx.core.ScrollView)
  288.          {
  289.             _loc1_ = _loc4_;
  290.             false;
  291.          }
  292.          _loc4_ = _loc4_._parent;
  293.       }
  294.       if(_loc1_ != undefined)
  295.       {
  296.          _loc4_ = delta > 0 ? -1 : 1;
  297.          var _loc2_ = _loc1_.vScroller.lineScrollSize;
  298.          if(_loc2_ == undefined)
  299.          {
  300.             _loc2_ = 0;
  301.          }
  302.          _loc2_ = Math.max(Math.abs(delta),_loc2_);
  303.          var _loc3_ = _loc1_.vPosition + _loc2_ * _loc4_;
  304.          _loc1_.vPosition = Math.max(0,Math.min(_loc3_,_loc1_.maxVPosition));
  305.          _loc1_.dispatchEvent({type:"scroll",direction:"vertical",position:_loc1_.vPosition});
  306.       }
  307.    }
  308.    function createChildren(Void)
  309.    {
  310.       super.createChildren();
  311.       if(this.mask_mc == undefined)
  312.       {
  313.          this.mask_mc = this.createObject("BoundingBox","mask_mc",this.MASK_DEPTH);
  314.       }
  315.       this.mask_mc._visible = false;
  316.    }
  317.    function invalidate(Void)
  318.    {
  319.       super.invalidate();
  320.    }
  321.    function draw(Void)
  322.    {
  323.       this.size();
  324.    }
  325.    function size(Void)
  326.    {
  327.       super.size();
  328.    }
  329.    function scrollProxy(docObj)
  330.    {
  331.       this._parent.onScroll(docObj);
  332.    }
  333.    function onScroll(docObj)
  334.    {
  335.       var _loc3_ = docObj.target;
  336.       var _loc2_ = _loc3_.scrollPosition;
  337.       if(_loc3_ == this.vScroller)
  338.       {
  339.          var _loc4_ = "vertical";
  340.          var _loc5_ = "__vPosition";
  341.       }
  342.       else
  343.       {
  344.          _loc4_ = "horizontal";
  345.          _loc5_ = "__hPosition";
  346.       }
  347.       this[_loc5_] = _loc2_;
  348.       this.dispatchEvent({type:"scroll",direction:_loc4_,position:_loc2_});
  349.    }
  350.    function setEnabled(v)
  351.    {
  352.       this.vScroller.enabled = this.hScroller.enabled = v;
  353.    }
  354.    function childLoaded(obj)
  355.    {
  356.       super.childLoaded(obj);
  357.       obj.setMask(this.mask_mc);
  358.    }
  359. }
  360.